﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DDOS.Objects;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace DDOS.Game_State
{
    class MinionGambitLayer : ScreenLayer
    {
        private Player player;
        private bool loading = true;
        private bool unloading = false;
        private Vector2 menuPos;
        private  Minion minion;
        private Vector2 baseGambit;


        public MinionGambitLayer(Minion m)
            :base(true)
        {
            minion = m;
            loading = true;
            unloading = false;
            menuPos = new Vector2(90, 720);
            baseGambit = new Vector2(100, 300);

        }

        
        public void OnLoad()
        {
            
            if (menuPos.Y > 175)
            {
               
                menuPos.Y -= 5;
                for (int i = 0; i < 4; i++)
                {
                }
            }
            else
            {
                loading = false;
            }
        }

        public void OnExit()
        {
            if (menuPos.Y < 720)
            {
                menuPos.Y += 5;
                for (int i = 0; i < 4; i++)
                {
                    
                }
            }
            else
            {
                unloading = false;
                ScreenManager.Instance.CurrentScreen.RemoveLayer(this);
            }
        }

        public override void  Update(GameTime gt)
        {
            if (loading)
            {
                OnLoad();
            }
            else
            {
                if (unloading)
                {
                    OnExit();
                }
                else
                {
                    if (InputManager.InputManagerInstance.GamePadButtonWasReleased(Buttons.B) ||
                        InputManager.InputManagerInstance.KeyWasReleased(Keys.Escape))
                        unloading = true;
                    if (InputManager.InputManagerInstance.GamePadButtonWasReleased(Buttons.A) ||
                        InputManager.InputManagerInstance.KeyWasReleased(Keys.Enter))
                    {
                        

                    }
                }
            }
        }

        public override void  Draw()
        {
            ScreenManager.Instance.CurrentSpriteBatch.Draw(ImageManager2D.Instance.Panel, menuPos, Color.White);
            ScreenManager.Instance.CurrentSpriteBatch.DrawString(FontManager.Instance.Times12, minion.ToString(), new Vector2(menuPos.X + (250 -FontManager.Instance.Times12.MeasureString(minion.ToString()).X/ 2), menuPos.Y + 10), Color.Red);

            for(int i =0; i <minion.Gambits.Count; i++)
            {
                ScreenManager.Instance.CurrentSpriteBatch.DrawString(FontManager.Instance.Times12, minion.Gambits[i].ToString(), new Vector2(baseGambit.X, baseGambit.Y + (35 * i)), Color.White);
            }

        }
    }
}
